﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Browser;

namespace PicasaManager
{
    public partial class OOBLogin : ChildWindow
    {

        public string SessionString { get; set; }

    
        public OOBLogin(string LoginUrl)
        {
            InitializeComponent();
            browser.ScriptNotify += new EventHandler<NotifyEventArgs>(browser_ScriptNotify);
            browser.Source = new Uri(LoginUrl, UriKind.Absolute);
        }

        void browser_ScriptNotify(object sender, NotifyEventArgs e)
        {
            string url = HttpUtility.UrlDecode(e.Value);
            string sessionString = HttpUtility.UrlDecode(new Uri(url).Query);
            SessionString = url;
            //sessionProperties = Facebook.Utility.JSONHelper.ConvertFromJSONAssoicativeArray(sessionString);
            
            this.DialogResult = true;
        }

        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = true;
        }

        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
        }
    }
}

